package JAVA300.第九章容器;

import java.util.HashMap;
import java.util.Map;

/**
 * 测试hashmap的使用
 */

public class TestMap {
    public static void main(String[] args) {
        Map<Integer,String> m1 = new HashMap<>();

        //存
        m1.put(1,"one");
        m1.put(2,"two");
        m1.put(3,"three");

        //取
        System.out.println(m1.get(1));

        //判断空
        System.out.println(m1.isEmpty());
        //判断键值包含
        System.out.println(m1.containsKey(2));
        System.out.println(m1.containsValue("one"));

        Map<Integer,String> m2 = new HashMap<>();

        m2.put(4,"f");
        m2.put(5,"wu");
        m2.put(6,"liu");

        m1.putAll(m2);
        System.out.println(m1);//{1=one, 2=two, 3=three, 4=f, 5=wu, 6=liu}




    }
}
